namespace Excerise;

public class Order
{
    public int OrderID { get; set; }
    public string CustomerName { get; set; }
    public List<Product> Products = new List<Product>();

    public Order(int orderID, string customerName)
    {
        OrderID = orderID;
        CustomerName = customerName;
    }

    public void AddProduct(Product product)
    {
        System.Console.WriteLine("添加产品成功");
        Products.Add(product);
    }

    public void RemoveProduct(Product product)
    {
        System.Console.WriteLine("移除产品成功");
        Products.Remove(product);
    }

    public void CalculateTotalPrice()
    {
        decimal sum = 0m;
        foreach (var item in Products)
        {
            sum += item.Price;
        }
        System.Console.WriteLine($"订单的总金额为:{sum}元");
    }

    public void DisplayOrderDetails()
    {
        System.Console.Write($"订单详细信息: 订单编号:{OrderID},客户姓名:{CustomerName},购买的产品列表:");
        foreach (var item in Products)
        {
            System.Console.Write($"{item.Name},");
        }
        CalculateTotalPrice();
    }
}